package org.msb.accentis.data.pojo;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Lob;
import javax.persistence.MappedSuperclass;

/**
 * The {@code NamedObject} class is extended by all model objects that are uniquely named. This class provides the ability to get and set a name as
 * well as a description.
 * 
 * @author Marc Boudreau
 * 
 * @since 1.0
 */
@MappedSuperclass
public abstract class NamedObject extends BaseObject implements Comparable<NamedObject> {

	@Basic
	@Column(unique=true)
	private String name;
	
	@Lob
	private String description;
	
	/**
	 * Returns the name of this object as a {@link String} object.
	 * 
	 * @return A {@link String} object containing the name.
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * Sets the name of this object to the provided {@link String} object.
	 * 
	 * @param value
	 *            A {@link String} object representing the name to set.
	 */
	public void setName(String value) {
		name = value;
	}

	/**
	 * Returns the description of this object as a {@link String} object.
	 * 
	 * @return A {@link String} object containing the description, or {@code null} if none has been set.
	 */
	public String getDescription() {
		return description;
	}
	
	/**
	 * Sets the description of this object to the provided {@link String} object.
	 * 
	 * @param value
	 *            A {@link String} object representing the description to set.
	 */
	public void setDescription(String value) {
		description = value;
	}
	
	@Override
	public int compareTo(NamedObject other) {
		return name.compareTo(other.getName());
	}

	@Override
	public String toString() {
		return getName();
	}
}
